package com.sr.controller.api;

import com.sr.annotation.ApiAuth;
import com.sr.annotation.Log;
import com.sr.constant.Constant;
import com.sr.controller.BaseController;
import com.sr.ibase.IBaseService;
import com.sr.pojo.WNavBar;
import com.sr.pojo.WType;
import com.sr.service.ITypeService;
import com.sr.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xiaochi
 * @date 2022/4/30 16:24
 * @desc TypeControllerApi
 */
@Api(tags = "资源类型")
@RestController
@RequiredArgsConstructor(onConstructor = @__)
@RequestMapping(Constant.Api.WEB_PREFIX+"/type")
public class TypeControllerApi extends BaseController {

    private final ITypeService typeService;

    /**
     * 查询所有导航
     * @return
     */
    @ApiAuth
    @Log(module = "测试日志",action = "测试日志方法")
    @GetMapping("/list/test")
    public R<List<WNavBar>> lists(){
        return R.ok();
    }

    /**
     * 查询所有类型
     * @return
     */
    @ApiOperation(value = "查询所有资源类型",notes = "查询所有资源类型")
    @GetMapping("/list/all")
    public R<List<WType>> list(){
        IBaseService.Criteria<WType> criteria = typeService.createCriteria(WType.class);
        criteria.andEqualTo(WType::getIsDel,1);
        return R.ok(typeService.findByWhere(criteria));
    }
}
